//
//  ControlsTableView.m
//  iBasic
//
//  Created by Andrew Barry on 30/04/08.
//  Copyright 2008 Barry Computer Services. All rights reserved.
//

#import "ControlsTableView.h"
#import "ControlsDataSource.h"
#import "ControlPanel.h"

@implementation ControlsTableView

- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *)tableColumns event:(NSEvent *)dragEvent offset:(NSPointPointer)dragImageOffset
{
	int idx = [dragRows firstIndex];

	NSString *controlType = [ControlsDataSource controlTypeForIndex:idx];
	NSSize sz = [ControlPanel defaultControlSize: controlType];
	int width = sz.width;
	int height = sz.height;
	
	NSImage *img = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] autorelease];
	[img lockFocus];
	[[NSColor colorWithCalibratedWhite:0.42 alpha:0.1] set];
	[NSBezierPath fillRect:NSMakeRect(0, 0, width, height)];
	[[NSColor colorWithCalibratedWhite:0.42 alpha:0.4] set];
	[NSBezierPath strokeRect:NSMakeRect(0, 0, width, height)];
	[img unlockFocus];
	return img;
	/*
	int idx = [dragRows firstIndex];
	
	NSString *imagePath = nil;
	
	if (idx == 0)
		imagePath = [[NSBundle mainBundle] pathForResource:@"button" ofType:@"png"];
	else if (idx == 1)
		imagePath = [[NSBundle mainBundle] pathForResource:@"label" ofType:@"png"];
	else if (idx == 2)
		imagePath = [[NSBundle mainBundle] pathForResource:@"check" ofType:@"png"];
	else if (idx == 3)
		imagePath = [[NSBundle mainBundle] pathForResource:@"radio" ofType:@"png"];

	if (imagePath == nil)
		return [super dragImageForRowsWithIndexes:dragRows tableColumns:tableColumns event:dragEvent offset:dragImageOffset];
	
	return [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
*/
}

@end
